﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TienTeTuong.back_end
{
    public partial class EditArticleCategory : System.Web.UI.Page
    {
        public ArticlecategoryDTO item = new ArticlecategoryDTO();
        public ArticlecategoryBUS cateBus = new ArticlecategoryBUS();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            if (Page.IsPostBack)
            {
                string id = Request.Params["id"] ?? "";
                item = cateBus.GetArtCateByID(id);
                item.CateName = txtName.Text;
                item.Description = txtDes.Text;
                item.Active = bool.Parse(isActive.Value);
                item.CateParent = txtParent.Text;
                item.VipLevel = int.Parse(txtViplevel.Text);
                cateBus.update(item);
                Response.Redirect("Articalecategorymanagement.aspx");
            }
            else
            {
                string id = Request.Params["id"] ?? "";
                item = cateBus.GetArtCateByID(id);
                txtName.Text = item.CateName;
                txtDes.Text = item.Description;
                isActive.Value = item.Active.ToString();
                txtParent.Text = item.CateParent;
                txtViplevel.Text = item.VipLevel.ToString();
            }
        }
    }
}